package cn.bytecollege.controller;

import cn.bytecollege.constant.Resource;
import cn.bytecollege.entity.Admin;
import cn.bytecollege.service.AdminService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 通过管理员名字在数据库中查找管理员
 * @author qy
 */
@WebServlet(name = "AdminFindMessageController", value = "/admin/findMessage")
public class AdminFindMessageController extends HttpServlet {
    AdminService adminService = new AdminService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");

        Admin admin = adminService.findByAdminName(username);

        admin.getAdminPassword();

        request.setAttribute("admin",admin);

        request.getRequestDispatcher(Resource.PAGE_LOCATION+"adminUpdate.jsp").forward(request,response);
    }
}
